﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnitLibrary.GameObjects;
using Microsoft.Xna.Framework;
using UnitLibrary.GameObjects.Units;


namespace UnitLibrary.Managers
{
    public class EnemyM: UnitM<Enemy> 
    {
        public EnemyM(Game game, ComponentM components)
            : base(game, components, UnitID.Enemy)
        {
        }
        private int _enemiesKilled = 0;
        private double _spawnDelay = 50;
        private double _timer = 0;
        public int EnemiesKilled
        {
            get { return _enemiesKilled; }
        }
        public override void LoadContent()
        {
            _unitManagerData = _components.ContentManager.Load<UnitManagerData>("content\\units\\managerdata\\managerdataenemies");
            _maxObjects = _unitManagerData.MaxNumberOfUnits;
            base.LoadContent();
        }
        public override void Remove(Iid id)
        {
            if (id.UnitID == UnitID.Enemy)
            {
                _enemiesKilled++;
                base.Remove(id);
            }
            else
                throw new Exception("");
        }
        public override void Update(GameTime gameTime)
        {
            _timer += gameTime.ElapsedGameTime.TotalMilliseconds;
            if (_timer > _spawnDelay){
                this.Create("default", new Vector2(Utility.Util.random.Next(0, 1200), Utility.Util.random.Next(0, 1200)), Vector2.Zero); _timer = 0; }
            base.Update(gameTime);
        }
    }
}
